package com.example.nonacademic_education.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.example.nonacademic_education.constant.Constant;
import com.example.nonacademic_education.data.request.TheClassList;
import com.example.nonacademic_education.entity.TheClass;
import com.example.nonacademic_education.service.impl.TheClassServiceImpl;
import com.example.nonacademic_education.util.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author:yanghua
 * @Date:2023/4/18 22:29
 */
@RestController
@RequestMapping("theclass")
public class TheClassController {
    @Resource
    private TheClassServiceImpl theClassService;
    @PostMapping("addOne")
    @SaCheckPermission("class.add")
    public R addOne(@RequestBody TheClass theClass){
        return theClassService.addOne(theClass);
    }
    @DeleteMapping("deleteOne")
    @SaCheckPermission("class.delete")
    public R deleteOne(Long id){
        return theClassService.deleteOne(id);
    }
    @PutMapping("updateOne")
    @SaCheckPermission("class.update")
    public R updateOne(@RequestBody TheClass theClass){
        return theClassService.updateOne(theClass);
    }
    @PostMapping("getList")
    @SaCheckPermission("class.query")
    public R getList(@RequestBody TheClassList theClassList){
        return theClassService.getLstList(theClassList);
    }
    @PostMapping("getIdAndNameList")
    @SaCheckRole(Constant.NORMAL_ADMIN)
    public R getIdAndName(@RequestBody TheClassList theClassList){
        return theClassService.getIdAndName(theClassList);
    }
}
